package com.googlecode.jlogindexer.client.utils;

import java.util.HashMap;
import java.util.List;

import noNamespace.AlertDocument.Alert;

public class JLogalizerAlertConfiguration {

	private  List<Alert> alerts;
	
	private HashMap<String, Alert> alertMap;
	
	private void populateAlertMap(){
		alertMap=new HashMap<String, Alert>();
		for (Alert alert: getAlerts()){
			alertMap.put(alert.getAlertName(), alert);
		}
	}
	
	public Alert getAlertByName(String alertName){
		Alert alert=null;
		if (alertMap==null){
			populateAlertMap();
		}
		
		if (alertName!=null){
			alert=alertMap.get(alertName);
		}
		
		return alert;
		
	}

	public List<Alert> getAlerts() {
		return alerts;
	}

	public void setAlerts(List<Alert> alerts) {
		this.alerts = alerts;
	}
}
